﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DevExpress.Web.ASPxGridView;
using DevExpress.Data;

public partial class viewer_Sales : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
       
        Session["current"] = "Sales by Branch";//current page
        if (Session["user"] != null)//check user
        {
            string user = Session["user"].ToString();
          

        }
        else
        {
            Response.Redirect("index.aspx");
        }
        if (!IsPostBack)
        {
            btnXlsExport.Visible = false;
            Panel1.Visible = false;
            Panel2.Visible = false;

        }


    }
    protected void ASPxComboBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
        btnXlsExport.Visible = true;
        string branch = ASPxComboBox1.SelectedItem.ToString();
        if (branch == "Kandy")
        {
            Panel1.Visible = true;
            Panel2.Visible = false;
            ASPxSummaryItem totalSummary = new ASPxSummaryItem();
            totalSummary.FieldName = "Total_Price";
            totalSummary.ShowInColumn = "Total_Price";
            totalSummary.SummaryType = SummaryItemType.Sum;
            totalSummary.DisplayFormat = "Total Rs.{0}";
            ASPxGridView1.TotalSummary.Add(totalSummary);
        }
        else
        {
            Panel2.Visible = true;
            Panel1.Visible = false;
            ASPxSummaryItem totalSummary = new ASPxSummaryItem();
            totalSummary.FieldName = "Total_Price";
            totalSummary.ShowInColumn = "Total_Price";
            totalSummary.SummaryType = SummaryItemType.Sum;
            totalSummary.DisplayFormat = "Total Rs.{0}";
            ASPxGridView2.TotalSummary.Add(totalSummary);
        }

    }

    protected void btnXlsExport_Click(object sender, EventArgs e)
    {
        gridExport.WriteXlsToResponse();
    }
}